#include "StandardMonster.h"

StandardMonster::StandardMonster(float x, float y, float z, int type):Monster(x, y, z) {
	this->monsterBox->setBox(x - 5.5F, y - 4.0F, z - 1.0F, 11.0F, 8.0F, 2.0F);
	this->type = type;
	this->score = type * 10 + 20;
}

void StandardMonster::init() {
	this->coord->setCoord3D(this->initCoord->x, this->initCoord->y, this->initCoord->z);
	this->tir->setCoord3D(this->coord->x, this->coord->y, this->coord->z);
	this->coordCharger->setCoord3D(this->coord->x, this->coord->y, this->coord->z);
	this->monsterBox->setBox(this->coord->x - 5.5F, this->coord->y - 4.0F, this->coord->z - 1.0F, 11.0F, 8.0F, 2.0F);
	isOnFire = false;
	isVisible = true;
	isCharger = false;
}

void StandardMonster::draw(){
	if (isVisible) {
		glPushMatrix();

		if (isOnFire) {
			glPushMatrix();
			glMaterialfv(GL_FRONT,GL_DIFFUSE,jaune);
			glTranslatef(this->tir->x, this->tir->y, this->tir->z);
			Figure::drawCuboid(1.0, 2.0, 1.0 );
			glPopMatrix();
		}

		glPushMatrix();
		if (isCharger) {
			glTranslatef(this->coordCharger->x, this->coordCharger->y, this->coordCharger->z);
		} else {
			glTranslatef(this->coord->x, this->coord->y, this->coord->z);
		}
	
		// pied Gauche
		switch (type) {
		case 1:
			glMaterialfv(GL_FRONT,GL_DIFFUSE,vert);
			break;

		case 2:
			glMaterialfv(GL_FRONT,GL_DIFFUSE,bleu);
			break;

		case 3:
			glMaterialfv(GL_FRONT,GL_DIFFUSE,jaune);
			break;
		}
		glPushMatrix();
		glTranslatef(-4.5F, -3.5F, 0.0F);
		Figure::drawCuboid( 2.0, 1.0, 2.0 );
		glTranslatef(0.5F, 1.0F, 0.0F);
		Figure::drawCuboid( 3.0, 1.0, 2.0 );
		glTranslatef( 1.0F, 1.0F, 0.0F);
		Figure::drawCuboid( 3.0, 1.0, 1.0 );
		glPopMatrix();

		// pied Droite
		glPushMatrix();
		glTranslatef(4.5F, -3.5F, 0.0F);
		Figure::drawCuboid( 2.0, 1.0, 2.0 );
		glTranslatef(-0.5F, 1.0F, 0.0F);
		Figure::drawCuboid( 3.0, 1.0, 2.0 );
		glTranslatef( -1.0F, 1.0F, 0.0F);
		Figure::drawCuboid( 3.0, 1.0, 1.0 );
		glPopMatrix();

		//bras gauche
		glPushMatrix();
		glTranslatef( -5.0F, 1.0F, 0.0F);
		Figure::drawCuboid( 1.0, 2.0, 1.0 );
		glTranslatef( 1.5F, -0.5F, 0.0F);
		Figure::drawCuboid( 2.0, 1.0, 1.0 );
		glPopMatrix();

		//bras droit
		glPushMatrix();
		glTranslatef( 5.0F, 1.0F, 0.0F);
		Figure::drawCuboid( 1.0, 2.0, 1.0 );
		glTranslatef( -1.5F, -0.5F, 0.0F);
		Figure::drawCuboid( 2.0, 1.0, 1.0 );
		glPopMatrix();

		//antenne haut
		glPushMatrix();
		glTranslatef( -1.0F, 3.0F, 0.0F);
		Figure::drawCuboid( 1.0, 2.0, 1.0 );
		glTranslatef( 2.0F, 0.0F, 0.0F);
		Figure::drawCuboid( 1.0, 2.0, 1.0 );
		glPopMatrix();

		//bas
		glPushMatrix();
		glTranslatef( -1.0F, -2.0F, 0.0F);
		Figure::drawCuboid( 1.0, 2.0, 1.0 );
		glTranslatef( 1.0F, -1.0F, 0.0F);
		Figure::drawCuboid( 1.0, 2.0, 1.0 );
		glTranslatef( 1.0F, 1.0F, 0.0F);
		Figure::drawCuboid( 1.0, 2.0, 1.0 );
		glPopMatrix();

		//visage
		glPushMatrix();
		glTranslatef( 0.0F, 1.5F, 0.0F);
		Figure::drawCuboid( 5.0, 1.0, 2.0 );
		glTranslatef( 0.0F, -1.0F, 0.0F);
		Figure::drawCuboid( 1.0, 1.0, 2.0 );
		glTranslatef( -2.0F, 0.0F, 0.0F);
		Figure::drawCuboid( 1.0, 1.0, 2.0 );
		glTranslatef( 4.0F, 0.0F, 0.0F);
		Figure::drawCuboid( 1.0, 1.0, 2.0 );
		glTranslatef( -2.0F, -1.0F, 0.0F);
		Figure::drawCuboid( 5.0, 1.0, 2.0 );
		glTranslatef( 0.0F, -1.0F, 0.0F);
		Figure::drawCuboid( 1.0, 1.0, 2.0 );
		glPopMatrix();

		//les yeux
		glMaterialfv(GL_FRONT,GL_DIFFUSE,rouge);
		glPushMatrix();
		glTranslatef(-1.0F, 0.5F, 0.0F);
		Figure::drawCuboid( 1.0, 1.0, 1.0 );
		glTranslatef(2.0F, 0.0F, 0.0F);
		Figure::drawCuboid( 1.0, 1.0, 1.0 );
		glPopMatrix();
		glMaterialfv(GL_FRONT,GL_DIFFUSE,blanc);

		glPopMatrix();
		glPopMatrix();
	}
}

